import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/user/login',
    method: 'post',
    data
  })
}

export function getInfo(data) {
  return request({
    url: '/user/getInfo/'+data,
    method: 'post',
  })
}

export function logout(data) {
  return request({
    url: '/user/logout/'+data,
    method: 'post'
  })
}
/* 查询用户的所有课程（包括必修选修） */
export function findAllUser() {
  return request({
    url: '/user/findAllUser',
    method: 'get'
  })
}

export function findMyItemSum(uid) {
  return request({
    url: 'item/findMyItemSum/' + uid,
    method: 'post'
  })
}

export function findAllItem(formInLine) {
  return request({
    url: 'item/findAllItem',
    method: 'post',
    data: formInLine
  })
}

// 查询个人信息
export function findUserById(id) {
  return request({
    url: '/user/findUserById/' + id,
    method: 'get'
  })
}

// 修改个人信息
export function updateUser(user) {
  return request({
    url: '/user/updateUser',
    method: 'post',
    data: user
  })
}
/* 我的必修数 */
export function findMyRequiredSum(uid){
  return request({
    url:'/course/findMyRequiredSum/'+uid,
    method:'post'
  })
}
/* 我的选修数 */
export function findMyElectiveSum(uid){
  return request({
    url:'/course/findMyElectiveSum/'+uid,
    method:'post'
  })
}

export function findAllRequired(courseFindByPage){
  return request({
    url:'course/findAllRequired',
    method: 'post',
    data: courseFindByPage
  })
}

export function findAllElective(courseFindByPage){
  return request({
    url:'course/findAllElective',
    method: 'post',
    data: courseFindByPage
  })
}

// 验证密码
export function validatePassword(data) {
  return request({
    url: '/user/validatePassword',
    method: 'post',
    data: data
  })
}

// 修改密码
export function updatePassword(data) {
  return request({
    url: '/user/updatePassword',
    method: 'post',
    data: data
  })
}

// 修改头像
export function uploadPicture(data) {
  return request({
    url: '/user/uploadPicture',
    method: 'post',
    data: data
  })
}

export function getStudent(userId) {
  return request({
    url: '/user/getStudentById/' + userId,
    method: 'post'

  })
}
//查询该用户能力
export function findAmById(userId) {
  return request({
    url: '/user/findAmById/' + userId,
    method: 'post'

  })
}

//查询用户所有的培训项目和能力
export function findCourseAndItem(userId) {
  return request({
    url: '/user/findCourseAndItem/' + userId,
    method: 'post'
  })
}

//查询用户所有未报名的项目
export function findNoJoinItem(data) {
  return request({
    url: '/user/findNoJoinItem',
    method: 'post',
    data
  })
}

//报名培训项目
export function applyItem(data) {
  return request({
    url: '/user/applyItem',
    method: 'post',
    data
  })
}

